function Tab(el,options={w:'580px',h:'180px'}){
this.el=document.querySelector(el)//el指box
this.options = options
this.num = 1
this.t = null 
this.init()//调用特效函数
}
Tab.prototype.init=function(){

this.auto()
this.over()
this.resetOptions()
}
Tab.prototype.resetOptions = function() {
this.el.style.width = this.options.w
this.el.style.height = this.options.h
}
Tab.prototype.page = function(num){
this.el.querySelector("ul li.active").className=""
this.el.querySelectorAll(" ul li")[num-1].className="active"
}
Tab.prototype.auto=function(){
this.t=setInterval(()=>{
this.num++
if(this.num>6) this.num=1
this.el.querySelector("img").src=`./imgs/img${this.num}.jpg`
this.page(this.num)
},1000)
}
Tab.prototype.over=function(){
let arr=this.el.querySelectorAll(" ul li")
arr.forEach((item,i)=>{
item.onmouseover=() => {
clearInterval(this.t)
this.el.querySelector("img").src=`./imgs/img${i+1}.jpg`
this.num=i+1
this.page(this.num)
}
item.onmouseout = ()=>{
this.out()
}
})
}
Tab.prototype.out = function(){
this.auto()
}
export default Tab

 
